home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Interactive Reference Guide
/
C-C++ Interactive Reference Guide.iso
/
c_ref
/
csource3
/
183_01
/
msc_asm.doc
< prev
next >
Wrap
Text File
|
1985-10-27
|
3KB
|
115 lines
Using Assembler with Microsoft C ver 3 and up
This program is an attempt to demonstrate the ues of assembly language
routines with MS C.
The latest version of Microsoft C has a function called intdos that
generates a DOS function call. This would be the easy way out namely
CLS and CPOS (position the cursor). But there are times when you need
to do things *** this *** way.
I hope you find this information helpful. I have tried hard to keep it
error free. If I have failed in this, or if you have suggestions,
comments, or criticisms, I'd be pleased to hear them.
My address is as follows:
John Scarfone
P.O. Box 2055
Windsor, Ontario
Canada
N8Y 4R5
My current UID is 75236,521.
#include <stdio.h>
main()
{
cls(); /* call cls */
cpos(10, 10); /* position the cursor at row 10 col 10 */
printf("It works!!!!!!");
}
title CLEARS the SCREEN
name CLS
COMMENT @
This is the source code for 'C' function CLS. This function
does exactly the same thing as CLS in Dos.
You must use the underscore as I did and you must use
_text for the small model.
@
assume cs:_text
_text segment public byte 'code'
public _cls
_cls proc near
push bp
mov bp,sp
mov ax,0600h ; Scroll the whole screen
mov cx,0000 ; From 0,0 to ...
mov dx,184fh ; Row 24, Col 79.
mov bh,07 ; Normal attribute
int 10h
mov ah,02 ; Set cursor function
mov dx,0000 ; Row, Col 0,0
mov bh,00 ; Page 0
int 10h
pop bp
ret
_cls endp
_text ends
end
title POSTION THE CURSOR
name CPOS
COMMENT @
This is the source code for the 'C' function CPOS (ROL, COL);
that does exactly what it sounds like it does.
Usage:
INT ROW, COL; /* assign the value 0, 0 to 24, 79 */
@
assume cs:_text
_text segment public byte 'code'
public _cpos
_cpos proc near
push bp
mov bp,sp
mov dx,[bp + 4] ; Skip over return address,
; and save bp, and get left parm (ROW)
mov ax,[bp + 6] ; Get second parm (COL)
pop bp
mov dh,dl ; Row in dh
mov dl,al ; Col in dl
mov ah,02 ; Function set cursor position
mov bh,00 ; Page 0
int 10h
ret
_cpos endp
_text ends
end